package com.fxb.project.exam.three;

import com.fxb.project.designpattern.chain.MargoIntercepting;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

public class Test33 implements MouseMotionListener {
    private JFrame frame;
    private JLabel tf;
    public static void main(String[] args) {
        Test33 two = new Test33();
        two.go();
    }

    public void go() {
        frame = new JFrame("Mouse control");
        Container contentPane = frame.getContentPane();
        contentPane.add(new JLabel("get mouse event"),BorderLayout.NORTH);
        tf = new JLabel();
        contentPane.add(tf,BorderLayout.SOUTH);
        frame.addMouseMotionListener(this);
        frame.setSize(300,300);
        frame.setVisible(true);
    }

    @Override
    public void mouseDragged(MouseEvent e) {
        String s = "Mouse Dragged:X="+e.getX()+"Y="+e.getY();
        tf.setText(s);
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        String s = "Mouse Moved:X="+e.getX()+"Y="+e.getY();
        tf.setText(s);
    }
}
